<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class RoleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
                'name' => 'required|unique:roles',
                'display_name'=>'required|unique:roles',
                'description'=>'required',
                'permission'=>'required'
            ];
    }
    public function messages(){
        return [
            'name.required' => '唯一标识必填',
            'name.unique'   => '标识一存在',
            'description.required' => '简介必填',
            'display_name.required' => '显示名称必填',
            'display_name.unique' => '显示名称已存在',
            'permission.required' =>'请至少选择一个',
        ];
    }    
}